function cubeFlag= isCubeCollision(cubeInfo,nearCoor,newCoor,step)
%判断长方体是否发生碰撞，碰撞则返回1

cubeFlag=0;

if cubeInfo.exist
    for k1=size(cubeInfo.axisX,2)
        xMin=cubeInfo.axisX(k1);
        xMax=xMin+cubeInfo.length(k1);
        yMin=cubeInfo.axisY(k1);
        yMax=yMin+cubeInfo.length(k1);
        zMin=cubeInfo.axisZ(k1);
        zMax=zMin+cubeInfo.length(k1);

        for k2=0:step/100:step
            deltaX=newCoor(1)-nearCoor(1);
            deltaY=newCoor(2)-nearCoor(2);
            deltaZ=newCoor(3)-nearCoor(3);

            r=sqrt(deltaX^2+deltaY^2+deltaZ^2);
            fai=atan2(deltaY,deltaX);
            theta=acos(deltaZ/r);

            x=k2*sin(theta)*cos(fai);
            y=k2*sin(theta)*sin(fai);
            z=k2*cos(theta);

            checkPoint=[x+nearCoor(1),y+nearCoor(2),z+nearCoor(3)];

            if (xMin<checkPoint(1) & checkPoint(1)<xMax) & (yMin<checkPoint(2) & checkPoint(2)<yMax) & (zMin<checkPoint(3) & checkPoint(3)<zMax)
                cubeFlag=1;
                return;
            end
        end
    end
end

end
